<!DOCTYPE html>
<script src="../../resources/testharness.js"></script>
<script src="../../resources/testharnessreport.js"></script>
<title>SVG bounding boxes are valid for a zero-width or zero-height circle</title>
<svg height="0">
  <circle cx="300" cy="300" r="50"/>
  <circle cx="300" cy="300" r="0"/>
  <circle vector-effect="non-scaling-stroke" cx="300" cy="300" r="50"/>
  <circle vector-effect="non-scaling-stroke" cx="300" cy="300" r="0"/>
</svg>
<script>
BBox = function(x,y,w,h) {
  this.x = x;
  this.y = y;
  this.width = w;
  this.height = h;
};
BBox.prototype.toString = function() {
  return this.x + "," + this.y + "," + this.width + "," + this.height;
};
// The order of expected sizes should equal the document order of the rects.
var expectedBoxes = [
  new BBox(250, 250, 100, 100),
  new BBox(300, 300, 0, 0),
  new BBox(250, 250, 100, 100),
  new BBox(300, 300, 0, 0),
];
var circles = document.getElementsByTagName('circle');
for (var i = 0, length = circles.length; i < length; ++i) {
     var circleBBox = circles[i].getBBox();
     test(function() {
         assert_equals(circleBBox.x, expectedBoxes[i].x);
         assert_equals(circleBBox.y, expectedBoxes[i].y);
         assert_equals(circleBBox.width, expectedBoxes[i].width);
         assert_equals(circleBBox.height, expectedBoxes[i].height);
     }, 'Bounding box size, circle ' + (i + 1) + ', ' + expectedBoxes[i]);
}
</script>
